package net.chenlin.dp.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.modules.business.entity.dto.deviceCalibration.CalibrationParam;
import net.chenlin.dp.modules.business.entity.dto.deviceCalibration.CheckParam;
import net.chenlin.dp.modules.business.entity.dto.deviceCalibration.CountRatioDto;
import net.chenlin.dp.modules.business.entity.dto.deviceCalibration.DeviceCalibrationDetailDto;
import net.chenlin.dp.modules.business.entity.vo.deviceCalibration.DeviceCalibrationCheckVo;
import net.chenlin.dp.modules.business.entity.vo.deviceCalibration.DeviceCalibrationDetailVo;
import net.chenlin.dp.modules.business.entity.vo.deviceCalibration.DeviceCalibrationListVo;
import net.chenlin.dp.modules.business.entity.vo.deviceCalibration.StepVo;
import net.chenlin.dp.modules.business.service.DeviceCalibrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author Yangsm
 * @ClassName: DeviceCalibrationController
 * @Description: TODO
 * @date 2023年11月23日 16:10
 */
@Slf4j
@RestController
@RequestMapping("/deviceCalibration")
@Api(tags = "设备校准")
public class DeviceCalibrationController {

    @Autowired
    private DeviceCalibrationService deviceCalibrationService;

    @RequestMapping(value = "/getDeviceCalibrationList", method = RequestMethod.POST)
    @ApiOperation(value = "查询设备校准列表")
    public Page<DeviceCalibrationListVo> getDeviceCalibrationList(@RequestBody Map<String, Object> params) {
        return deviceCalibrationService.getDeviceCalibrationList(params);
    }

    @RequestMapping(value = "/calibration", method = RequestMethod.POST)
    @ApiOperation(value = "开始校准")
    public R calibration (@RequestBody CalibrationParam param) throws ParseException {
        deviceCalibrationService.calibration(param);
        return R.ok();
    }

    @RequestMapping(value = "/getDeviceCalibrationResult", method = RequestMethod.POST)
    @ApiOperation(value = "查询设备校准结果列表")
    public List<DeviceCalibrationDetailVo> getDeviceCalibrationResult(@RequestBody Map<String, Object> params) {
        return deviceCalibrationService.getDeviceCalibrationResult(params);
    }

    @RequestMapping(value = "/check", method = RequestMethod.POST)
    @ApiOperation(value = "开始复核")
    public R check (@RequestBody CheckParam param) throws ParseException {
        deviceCalibrationService.check(param);
        return R.ok();
    }

    @RequestMapping(value = "/getDeviceCalibrationCheckResult", method = RequestMethod.POST)
    @ApiOperation(value = "查询设备复核列表")
    public Page<DeviceCalibrationCheckVo> getDeviceCalibrationCheckResult(@RequestBody Map<String, Object> params) {
        return deviceCalibrationService.getDeviceCalibrationCheckResult(params);
    }

    @RequestMapping(value = "/getStep", method = RequestMethod.GET)
    @ApiOperation(value = "查询校准在哪一步")
    public R getStep () {
        return deviceCalibrationService.getStep();
    }

    @RequestMapping(value = "/countRatio", method = RequestMethod.POST)
    @ApiOperation(value = "计算系数")
    public R countRatio (@RequestBody CountRatioDto dto) throws ParseException {
        return deviceCalibrationService.countRatio(dto);
    }

    @RequestMapping(value = "/getDeviceCalibrationDetailList", method = RequestMethod.POST)
    @ApiOperation(value = "查询设备校准校准完成的列表")
    public Page<DeviceCalibrationDetailVo> getDeviceCalibrationDetailList(@RequestBody Map<String, Object> params) {
        return deviceCalibrationService.getDeviceCalibrationDetailList(params);
    }

    @RequestMapping(value = "/updateCalibrationFactor", method = RequestMethod.POST)
    @ApiOperation(value = "修改设备相序的校准系数")
    public R updateCalibrationFactor(@RequestBody DeviceCalibrationDetailDto dto) {
        return deviceCalibrationService.updateCalibrationFactor(dto);
    }

}
